<template>
  <div class="home">
  </div>
</template>

<script>
// 取消请求
import axios from 'axios'
export default {
  name: 'axios3-5',
  created(){
    //axios.get('/cache/get',{params:{key:12}})

    let source = axios.CancelToken.source()
    axios.delete('/cache/delete',{cancelToken:source.token})
         .then(res=>{
            console.log(res)
          })
          .catch(err=>{
            console.log(err)
          })
    //取消请求message
    setTimeout(()=>{
        //什么时候用到这个请求：长时间后端未返回
        source.cancel('取消请求啦！')
    },3000)
  
    

  }
}
</script>
